import AxiosInterceptorManager from './AxiosInterceptorManager'
export type Methods = 'get' | 'post' | 'GET' | 'POST' | 'put' | 'PUT' | 'delete' | 'DELETE' | 'options' | 'OPTIONS'
// type Record<K extends string | number | symbol, T> = { [P in K]: T; }
export interface AxiosRequestConfig {
    url?: string,
    method?: Methods,
    params?: any,
    //新语法 代表： (key:string):(value:any)
    headers?: Record<string, any>,
    data?: Record<string, any>,
    timeout?: number,
    transformRequest?: (data: Record<string, any>, headers: any) => any,
    transformResponse?: (data: any) => any,
    cancelToken?: any;
    isCancel?: any

}
// 用来修饰 Axios.prototype.request 这个方法的
// Promise的泛型T代表此Promise变成成功态之后resolve的值 resolve(value)
export interface AxiosInstance {
    <T>(config: AxiosRequestConfig): Promise<AxiosResponse<T>>,
    interceptors: {
        request: AxiosInterceptorManager<AxiosRequestConfig>
        response: AxiosInterceptorManager<AxiosResponse>
    }
    cancelToken: any;
    isCancel: any
}
// 泛型T代表响应体的类型
export interface AxiosResponse<T = any> {
    data: T;
    status: number;
    statusText: string;
    headers?: Record<string, any>,
    config?: AxiosRequestConfig;
    request?: XMLHttpRequest
}